/*
 * @Author: ZephyrGao
 * @Date: 2023-10-31 17:31:01
 * @Description: 工具类
 * Copyright (c) 2023 by ZephyrGao, All Rights Reserved. 
 */

import 'dart:io';

import 'package:flutter/foundation.dart';

enum PlatInfo {
  ios,
  android,
  fuchsia,
  web,
  window,
  macOs,
  linux,
  other,
}

class CommonUtil {
  /// 判断是否为本地图片
  static bool isLocalImage(String? imagePath) {
    if (imagePath == null) {
      return false;
    }
    return imagePath.startsWith('images/');
  }

  /// 判断平台信息
  static PlatInfo curPlatForm() {
    PlatInfo platform = PlatInfo.other;
    if (Platform.isAndroid) {
      platform = PlatInfo.android;
    } else if (Platform.isIOS) {
      platform = PlatInfo.ios;
    } else if (Platform.isFuchsia) {
      platform = PlatInfo.fuchsia;
    } else if (Platform.isMacOS) {
      platform = PlatInfo.macOs;
    } else if (Platform.isWindows) {
      platform = PlatInfo.window;
    } else if (Platform.isLinux) {
      platform = PlatInfo.linux;
    } else if (kIsWeb) {
      platform = PlatInfo.web;
    }
    return platform;
  }
}
